package com.xyht.sca_s.student_manage_system.modules.questionnaire.controller;


import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.questionnaire.service.SmsQuestionnaireAnalysisService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 数据分析 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-02-08
 */
@RestController
@RequestMapping("/questionnaire/analysis")
@SecretBody
public class SmsQuestionnaireAnalysisController {
    @Autowired
    private SmsQuestionnaireAnalysisService smsQuestionnaireAnalysisService;

    @ApiModelProperty(value = "数据分析统计报表")
    @GetMapping("/formDate")
    public ResponseResult getFormData(@RequestParam("ques_id") String ques_id,
                                      @RequestParam(value = "bg_date", required = false) String bg_date,
                                      @RequestParam(value = "end_date", required = false) String end_date) {
        return smsQuestionnaireAnalysisService.getFormData(ques_id, bg_date, end_date);
    }

    @ApiModelProperty(value = "数据分析统计报表")
    @GetMapping("/formDateDetail")
    public ResponseResult getTopicFormDataDetail(@RequestParam("topic_id") String topic_id,
                                                 @RequestParam(value = "option_id", required = false) List<String> option_id,
                                                 @RequestParam(value = "name_str", required = false) String name_str,
                                                 @RequestParam(value = "option_str", required = false) String option_str,
                                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                 @RequestParam(value = "bg_date", required = false) String bg_date,
                                                 @RequestParam(value = "end_date", required = false) String end_date) {
        return smsQuestionnaireAnalysisService.getTopicFormDataDetail(topic_id, option_id, name_str,
                option_str, pageNum, pageSize,
                bg_date, end_date);
    }

    @ApiModelProperty(value = "数据记录")
    @GetMapping("/dataRecord")
    public ResponseResult getDataRecord(@RequestParam("ques_id") String ques_id,
                                        @RequestParam(value = "user_str", required = false) String user_str,
                                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                        @RequestParam(value = "bg_date", required = false) String bg_date,
                                        @RequestParam(value = "end_date", required = false) String end_date) {
        return smsQuestionnaireAnalysisService.getDataRecord(ques_id, user_str,bg_date,end_date, pageNum, pageSize);
    }

    @ApiModelProperty(value = "数据记录详情")
    @GetMapping("/dataRecordDetail")
    public ResponseResult getDataRecordDetail(@RequestParam("ques_id") String ques_id,
                                        @RequestParam(value = "user_id") String user_id) {
        return smsQuestionnaireAnalysisService.getDataRecordDetail(ques_id, user_id);
    }
}

